package com.dingwen.treasure.file.generate.controller;

import com.dingwen.treasure.base.controller.BaseViewController;
import com.dingwen.treasure.base.pojo.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 视图控制器
 *
 * @author dingwen
 * @date 2022/03/10
 */
@Api(tags = "PDF预览")
@Controller
@RequestMapping("/view")
public class ViewController implements BaseViewController {

    /**
     * 请求
     */
    @Resource
    private  HttpServletRequest request;

    /**
     * 你好
     *
     * @return {@link String}
     */
    @ApiOperation("PDF在线预览")
    @GetMapping("test")
    public Result<String> hello(){
        // 塞数据
        pushPageData();
        return success("hello",true);
    }

    /**
     * 放数据到页面
     */
    private void pushPageData() {
        request.setAttribute("title","TEST");
        request.setAttribute("content","TALK IS CHEAP SHOW ME THE CODE");
    }
}
